package com.yxq.mdt.app.modules.socialcontact.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.socialcontact.bean.GivePresentBean;
import com.yxq.mdt.app.modules.socialcontact.bean.SocialPersonalHomepageBean;
import com.yxq.mdt.app.modules.socialcontact.bean.SocialPersonalMyHomepageBean;
import com.yxq.mdt.app.modules.socialcontact.model.MainSocialContactModel;
import com.yxq.mdt.app.net.ApiModel;

public class MainSocialPersonalHomePresenter extends BasePresenter<mainSocialPersonalHomeContract.View, MainSocialContactModel> implements mainSocialPersonalHomeContract.Presenter {


    /**
     * 如果当前页面同时需要 Model 层和 View 层,则使用此构造函数(默认)
     *
     * @param rootView
     * @param model
     */
    public MainSocialPersonalHomePresenter(mainSocialPersonalHomeContract.View rootView, MainSocialContactModel model) {
        super(rootView, model);
    }


    @Override
    public void getMyGaUserExtVoById() {
        mBaseModel.getMyGaUserExtVoById(new ApiModel.CommonCallback<SocialPersonalMyHomepageBean>() {
            @Override
            public void onSuccess(SocialPersonalMyHomepageBean socialPersonalMyHomepageBean) {
                mRootView.onLoadMyGaUserExtVoByIdSuccess(socialPersonalMyHomepageBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadMyGaUserExtVoByIdFailed();
            }
        });
    }

    @Override
    public void getGaUserExtVoById(String userId) {
        mBaseModel.getGaUserExtVoById(userId, new ApiModel.CommonCallback<SocialPersonalHomepageBean>() {
            @Override
            public void onSuccess(SocialPersonalHomepageBean socialPersonalHomepageBean) {
                mRootView.onLoadGaUserExtVoByIdSuccess(socialPersonalHomepageBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadGaUserExtVoByIdFailed();
            }
        });
    }

    @Override
    public void getSelectByGsPresentPageList() {
        mBaseModel.getSelectByGsPresentPageList(new ApiModel.CommonCallback<GivePresentBean>() {
            @Override
            public void onSuccess(GivePresentBean givePresentBean) {
                mRootView.onLoadSelectByGsPresentPageListSuccess(givePresentBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadSelectByGsPresentPageListFailed();
            }
        });
    }

    @Override
    public void setInterestRelation(String toUserId, int enabled, int type) {
        mBaseModel.setInterestRelation(toUserId, enabled, type, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String s) {
                mRootView.onLoadRelationSuccess(s);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadRelationFailed();
            }
        });
    }
}
